<template>
	<view class="layout">
		<uni-header :leftIcon="true" :title="title"></uni-header>
		<view class="content">
			<view class="info">
				<view class="info-list">
					<view class="left">活动名称</view>
					<view class="right">{{activity.activity_name}}</view>
				</view>
				<view class="info-list">
					<view class="left">开始时间</view>
					<view class="right">{{activity.begin_time}}</view>
				</view>
				<view class="info-list" v-if="type !== 'teaching'">
					<view class="left">结束时间</view>
					<view class="right">{{activity.end_time}}</view>
				</view>
				<view class="info-list" v-if="type !== 'teaching'">
					<view class="left">活动学时</view>
					<view class="right">{{activity.hours}}</view>
				</view>
			</view>
			<view class="info">
				<view class="info-list">
					<view class="left">学段</view>
					<view class="right">{{activity.stagesName}}</view>
				</view>
				<view class="info-list">
					<view class="left">年级</view>
					<view class="right">{{activity.activity_grade}}</view>
				</view>
				<view class="info-list">
					<view class="left">学科</view>
					<view class="right">{{activity.subject_name}}</view>
				</view>
			</view>
			<view class="info">
				<view class="info-list" v-if="type !== 'teaching'">
					<view class="left">活动地点</view>
					<view class="right">{{activity.activity_add}}</view>
				</view>
				<view class="info-list" v-if="type === 'class' || type === 'emulate'">
					<view class="left">授课老师</view>
					<view class="right">{{activity.grant_teacher}}</view>
				</view>
				<view class="info-list" v-if="type === 'class' || type === 'emulate'">
					<view class="left">活动级别</view>
					<view class="right">{{activity.activity_level}}</view>
				</view>
				<view class="info-list" v-if="type === 'class' || type === 'emulate'">
					<view class="left">评价量表</view>
					<view class="right">{{activity.scale_name}}</view>
				</view>
				<view class="info-list" v-if="type !== 'teaching'">
					<view class="left">下发教员</view>
					<view class="right">{{activity.teachersNames}}</view>
				</view>

				<view class="info-list" v-if="type === 'teaching'">
					<view class="left">学校</view>
					<view class="right">{{activity.schoolName}}</view>
				</view>

				<view class="info-list" v-if="type === 'teaching'">
					<view class="left">老师</view>
					<view class="right">{{activity.teachersNames}}</view>
				</view>

				<view class="info-list" v-if="type === 'research'">
					<view class="left">说明</view>
					<view class="right">{{activity.comment}}</view>
				</view>

			</view>
		</view>
	</view>
</template>

<script>
	import {
		getActivity,
		getEmulateActivity,
		getResearchActivity,
		getTeachActivity
	} from "@/api/home"
	export default {
		data() {
			return {
				type: "",
				title: "",
				activeId: "",
				deviceId: this.$store.state.user.deviceId,
				activity: {}
			}
		},
		onLoad(option) {
			this.activeId = option.activeId;
			this.type = option.type;
			if (this.type == "class") {
				this.title = '常规教研活动信息'
				this.getClassActive();
			} else if (this.type == "teaching") {
				this.title = '教案抽查信息'
				this.getTeachActive()
			} else if (this.type == "research") {
				this.title = '主题教研信息'
				this.getResearchActive()
			} else if (this.type == "emulate") {
				this.title = '观摩课活动信息'
				this.getEmulateActive()
			}
		},
		methods: {
			//获取听评课下活动信息数据
			getClassActive() {
				getActivity({
					id: this.activeId,
					deviceId: this.deviceId
				}).then(res => {
					this.activity = res.activity;
				})
			},
			//获取教案抽查下活动信息数据
			getTeachActive() {
				getTeachActivity({
					teachingID: this.activeId,
					deviceId: this.deviceId
				}).then(res => {
					this.activity = res.checkDetails;
					this.activity.stagesName = res.checkDetails.periodName
					this.activity.activity_grade = res.checkDetails.grade
					this.activity.subject_name = res.checkDetails.subName
				})
			},
			//获取教研管理下活动信息数据
			getResearchActive() {
				getResearchActivity({
					id: this.activeId,
					deviceId: this.deviceId
				}).then(res => {
					this.activity = res.TeachRecord;
					this.activity.stagesName = res.TeachRecord.stagesname
					this.activity.subject_name = res.TeachRecord.subjectname
				})
			},
			//获取观摩课下活动信息数据
			getEmulateActive() {
				getEmulateActivity({
					id: this.activeId,
					deviceId: this.deviceId
				}).then(res => {
					this.activity = res.activity;
				})
			},
		}
	}
</script>

<style lang="scss">
	.layout {
		.content {
			.info {
				margin-bottom: 20px;

				.info-list {
					display: flex;
					justify-content: space-between;
					align-items: center;
					background: #fff;
					padding: 10px 15px;
					margin-bottom: 1px;

					.left {
						font-size: 16px;
						color: #5e5e5e;
					}

					.right {
						font-size: 14px;
						color: #666;
					}
				}
			}

		}
	}
</style>